home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / dsp / srffttar.z / srffttar / SRFFT / fftout68.c < prev    next >
C/C++ Source or Header  |  1991-08-26  |  7KB  |  254 lines

  1. /*-------------------------- fftout68.c --------------------------------*/
  2. /*                                                                      */
  3. /* Author:      Udi Finkelstein (based on code by Eyal Lebedinsky)      */
  4. /* Date:        Aug 91                                                  */
  5. /* Version:     26 Aug 1991                                             */
  6. /*                                                                      */
  7. /* called from fftg.c and generates 68K output                          */
  8. /*                                                                      */
  9. /* This program is released into the public domain.                     */
  10. /*                                                                      */
  11. /*----------------------------------------------------------------------*/
  12.  
  13. #include <stdio.h>
  14.  
  15. static int    label = 0;
  16.  
  17. void
  18. start_fft (file_name, ep_name)
  19. char    *file_name, *ep_name;
  20. {
  21.     char    fname[256];
  22.  
  23.     strcpy (fname, file_name);
  24.     strcat (fname, ".asm");
  25.  
  26.     freopen (fname, "wt", stdout);
  27.     printf ("%s:\n\tXDEF\t%s\n", ep_name, ep_name);
  28.     printf ("\tXREF\t_x\n\tXREF\t\_qf\n");
  29.     printf ("\tmovem.l\td0-d7/a0-a1,-(a7)\n");
  30.     printf ("\tlea\t_x,a0\n");
  31.     printf ("\tlea\t_qf,a1\n");
  32. }
  33.  
  34. void
  35. end_fft (file_name, ep_name)
  36. char    *file_name, *ep_name;
  37. {
  38.     printf (";finished here!\n");
  39.     printf ("\tmovem.l\t(a7)+,d0-d7/a0-a1\n");
  40.     printf ("\trts\n\n");
  41.     printf ("\tEND\n");
  42.     close (stdout);
  43. }
  44.  
  45. void
  46. fft1 (i1)
  47. int    i1;
  48. {
  49.     printf (";_fft1(%d)\n", i1);
  50.     printf ("\tasr.w\t%d(a0)\n", 2 * i1);
  51. }
  52.  
  53. void
  54. fft2 (i1, i2)
  55. int    i1, i2;
  56. {
  57.     printf (";_fft2(%d,%d)\n", i1, i2);
  58.     printf ("\tmove.w\t%d(a0),d1\n", 2 * i1);
  59.     printf ("\tmove.w\t%d(a0),d2\n", 2 * i2);
  60.     printf ("\tasr.w\t#1,d1\n");
  61.     printf ("\tasr.w\t#1,d2\n");
  62.     printf ("\tmove.w\td1,d0\n");
  63.     printf ("\tadd.w\td2,d0\n");
  64.     printf ("\tmove.w\td0,%d(a0)\n", 2 * i1);
  65.     printf ("\tsub.w\td2,d1\n");
  66.     printf ("\tmove.w\td1,%d(a0)\n", 2 * i2);
  67. }
  68.  
  69. void
  70. fft3 (i1, i3, i4)
  71. int    i1, i3, i4;
  72. {
  73.     printf (";_fft3(%d,%d,%d)\n", i1, i3, i4);
  74.     printf ("\tmove.w\t%d(a0),d1\n", 2 * i1);
  75.     printf ("\tmove.w\t%d(a0),d3\n", 2 * i3);
  76.     printf ("\tmove.w\t%d(a0),d4\n", 2 * i4);
  77.     printf ("\tasr.w\t#1,d1\n");
  78.     printf ("\tasr.w\t#1,d3\n");
  79.     printf ("\tasr.w\t#1,d4\n");
  80.     printf ("\tmove.w\td4,d0\n");
  81.     printf ("\tadd.w\td3,d0\n");
  82.     printf ("\tasr.w\t#1,d0\n");
  83.     printf ("\tsub.w\td3,d4\n");
  84.     printf ("\tasr.w\t#1,d4\n");
  85.     printf ("\tmove.w\td4,%d(a0)\n", 2 * i4);
  86.     printf ("\tmove.w\td1,d3\n");
  87.     printf ("\tsub.w\td0,d3\n");
  88.     printf ("\tmove.w\td3,%d(a0)\n", 2 * i3);
  89.     printf ("\tadd.w\td0,d1\n");
  90.     printf ("\tmove.w\td1,%d(a0)\n", 2 * i1);
  91. }
  92.  
  93. void
  94. fft4 (i1, i2, i3, i4, cc1)
  95. int    i1, i2, i3, i4, cc1;
  96. {
  97.     printf (";_fft4(%d,%d,%d,%d,0x%04x)\n", i1, i2, i3, i4, cc1);
  98.     printf ("\tmove.w\t%d(a0),d1\n", 2 * i1);
  99.     printf ("\tmove.w\t%d(a0),d2\n", 2 * i2);
  100.     printf ("\tasr.w\t#2,d1\n");
  101.     printf ("\tasr.w\t#1,d2\n");
  102.     printf ("\tmove.w\t%d(a0),d3\n", 2 * i3);
  103.     printf ("\tmove.w\t%d(a0),d4\n", 2 * i4);
  104.     printf ("\tmuls\t#%d,d3\n", cc1);
  105.     printf ("\tswap\td3\n");
  106.     printf ("\tmuls\t#%d,d4\n", cc1);
  107.     printf ("\tswap\td4\n");
  108.     printf ("\tmove.w\td3,d0\n");
  109.     printf ("\tsub.w\td4,d3\n");
  110.     printf ("\tadd.w\td0,d4\n");
  111.     printf ("\tmove.w\td2,d0\n");
  112.     printf ("\tsub.w\td4,d0\n");
  113.     printf ("\tmove.w\td0,%d(a0)\n", 2 * i4);
  114.     printf ("\tadd.w\td4,d2\n");
  115.     printf ("\tneg.w\td2\n");
  116.     printf ("\tmove.w\td2,%d(a0)\n", 2 * i3);
  117.     printf ("\tmove.w\td1,d0\n");
  118.     printf ("\tsub.w\td3,d0\n");
  119.     printf ("\tmove.w\td0,%d(a0)\n", 2 * i2);
  120.     printf ("\tadd.w\td3,d1\n");
  121.     printf ("\tmove.w\td1,%d(a0)\n", 2 * i1);
  122. }
  123.  
  124. void
  125. fft5 (i1, i2, i3, i4, i5, i6, i7, i8, sm1, sp1, cc1, sm3, sp3, cc3, ind)
  126. int    i1, i2, i3, i4, i5, i6, i7, i8, sm1, sp1, cc1, sm3, sp3, cc3, ind;
  127. {
  128.     printf (";_fft5(%d,%d,%d,%d,%d,%d,%d,%d,",
  129.         i1, i2, i3, i4, i5, i6, i7, i8);
  130.     printf ("0x%04x,0x%04x,0x%04x,0x%04x,0x%04x,0x%04x,%d)\n",
  131.         sm1, sp1, cc1, sm3, sp3, cc3, ind);
  132.     printf ("\tmove.w\t%d(a0),d5\n", 2 * i7);
  133.     printf ("\tmove.w\td5,d1\n");
  134.     printf ("\tmuls\t#%d,d1\n", sm1);
  135.     printf ("\tswap\td1\n");
  136.     printf ("\tmove.w\t%d(a0),d6\n", 2 * i3);
  137.     if (ind) printf ("\tasr.w\t#1,d6\n");
  138.     printf ("\tadd.w\td6,d5\n");
  139.     printf ("\tmove.w\td6,d2\n");
  140.     printf ("\tmuls\t#%d,d2\n", sp1);
  141.     printf ("\tswap\td2\n");
  142.     printf ("\tmuls\t#%d,d5\n", cc1);
  143.     printf ("\tswap\td5\n");
  144.     printf ("\tadd.w\td5,d1\n");
  145.     printf ("\tadd.w\td5,d2\n");
  146.  
  147.     printf ("\tmove.w\t%d(a0),d5\n", 2 * i8);
  148.     printf ("\tmove.w\td5,d3\n");
  149.     printf ("\tmuls\t#%d,d3\n", sm3);
  150.     printf ("\tswap\td3\n");
  151.     printf ("\tmove.w\t%d(a0),d6\n", 2 * i4);
  152.     if (ind) printf ("\tasr.w\t#1,d6\n");
  153.     printf ("\tadd.w\td6,d5\n");
  154.     printf ("\tmove.w\td6,d4\n");
  155.     printf ("\tmuls\t#%d,d4\n", sp3);
  156.     printf ("\tswap\td4\n");
  157.     printf ("\tmuls\t#%d,d5\n", cc3);
  158.     printf ("\tswap\td5\n");
  159.     printf ("\tadd.w\td5,d3\n");
  160.     printf ("\tadd.w\td5,d4\n");
  161.  
  162.     printf ("\tmove.w\td3,d5\n");
  163.     printf ("\tsub.w\td1,d5\n");
  164.  
  165.     printf ("\tmove.w\t%d(a0),d6\n", 2 * i2);
  166.     printf ("\tasr.w\t#1,d6\n");
  167.     printf ("\tmove.w\td5,d0\n");
  168.     printf ("\tsub.w\td6,d0\n");
  169.     printf ("\tmove.w\td0,%d(a0)\n", 2 * i7);
  170.     printf ("\tadd.w\td6,d5\n");
  171.     printf ("\tmove.w\td5,%d(a0)\n", 2 * i4);
  172.     printf ("\tmove.w\td2,d5\n");
  173.     printf ("\tadd.w\td4,d5\n");
  174.  
  175.     printf ("\tmove.w\t%d(a0),d6\n", 2 * i6);
  176.     printf ("\tasr.w\t#1,d6\n");
  177.     printf ("\tmove.w\td5,d0\n");
  178.     printf ("\tsub.w\td6,d0\n");
  179.     printf ("\tmove.w\td0,%d(a0)\n", 2 * i3);
  180.     printf ("\tadd.w\td6,d5\n");
  181.     printf ("\tmove.w\td5,%d(a0)\n", 2 * i8);
  182.     printf ("\tmove.w\td1,d5\n");
  183.     printf ("\tadd.w\td3,d5\n");
  184.  
  185.     printf ("\tmove.w\t%d(a0),d6\n", 2 * i1);
  186.     printf ("\tasr.w\t#1,d6\n");
  187.     printf ("\tmove.w\td6,d0\n");
  188.     printf ("\tsub.w\td5,d0\n");
  189.     printf ("\tmove.w\td0,%d(a0)\n", 2 * i6);
  190.     printf ("\tadd.w\td6,d5\n");
  191.     printf ("\tmove.w\td5,%d(a0)\n", 2 * i1);
  192.     printf ("\tmove.w\td2,d5\n");
  193.     printf ("\tsub.w\td4,d5\n");
  194.  
  195.     printf ("\tmove.w\t%d(a0),d6\n", 2 * i5);
  196.     printf ("\tasr.w\t#1,d6\n");
  197.     printf ("\tmove.w\td6,d0\n");
  198.     printf ("\tsub.w\td5,d0\n");
  199.     printf ("\tmove.w\td0,%d(a0)\n", 2 * i5);
  200.     printf ("\tadd.w\td5,d6\n");
  201.     printf ("\tmove.w\td6,%d(a0)\n", 2 * i2);
  202. }
  203.  
  204. void
  205. fft7 (i1, i2)
  206. int    i1, i2;
  207. {
  208.     printf (";_fft7(%d,%d)\n", i1, i2);
  209.     printf ("\tmove.w\t%d(a0),d0\n", 2 * i2);
  210. #ifdef _16BIT
  211. /* original routine had 16 bit input, we have 8 bit input, so.. */
  212.     printf ("\text.l\td0\n");
  213.     printf ("\tasl.l\t#1,d0\n");
  214. /*    lt1 *= lt1;\*/
  215.     printf ("\tswap\td0\n");
  216. #else
  217.     printf ("\tmuls\td0,d0\n");
  218.     printf ("\tswap\td0\n");
  219. /*    printf ("\tasl.w\t#1,d0\n");*/
  220. #endif
  221.     printf ("\tmove.w\td0,%d(a1)\n", 2 * i1);
  222. }
  223.  
  224. void
  225. fft8 (i1, i2, i3)
  226. int    i1, i2, i3;
  227. {
  228.     printf (";_fft8(%d,%d,%d)\n", i1, i2, i3);
  229. #ifdef _16BIT
  230. /* original routine had 16 bit input, we have 8 bit input, so.. */
  231.     printf ("\tmove.w\t%d(a0),d0\n", 2 * i2);
  232.     printf ("\text.l\td0\n");
  233.     printf ("\tasl.l\t#1,d0\n");
  234. /*    lt1 *= lt1;\*/
  235.     printf ("\tmove.w\t%d(a0),d1\n", 2 * i3);
  236.     printf ("\text.l\td1\n");
  237.     printf ("\tasl.l\t#1,d1\n");
  238. /*    lt2 *= lt2;\*/
  239.     printf ("\tadd.l\td1,d0\n");
  240.     printf ("\tswap\td0\n");
  241.     printf ("\tmove.w\td0,%d(a1)\n", 2 * i1);
  242. #else
  243.     printf ("\tmove.w\t%d(a0),d0\n", 2 * i2);
  244.     printf ("\tmuls\td0,d0\n");
  245.     printf ("\tswap\td0\n");
  246.     printf ("\tmove.w\t%d(a0),d1\n", 2 * i3);
  247.     printf ("\tmuls\td1,d1\n");
  248.     printf ("\tswap\td1\n");
  249.     printf ("\tadd.w\td1,d0\n");
  250. /*    printf ("\tasl.w\t#1,d0\n");*/
  251.     printf ("\tmove.w\td0,%d(a1)\n", 2 * i1);
  252. #endif
  253. }
  254.